/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file  EthBuff.h
 * @brief Semidrive. AUTOSAR 4.3.1 MCAL Eth plugins.
 */

#ifndef ETH_BUFF_H_
#define ETH_BUFF_H_

#ifdef __cplusplus
extern "C" {
#endif

/* illegal idx */
#define  ILLEGAL_BUFF_IDX 0xFFFFFFu
#define  ILLEGAL_BUFF_TYPE_IDX 0xFFFFu
/**
 * @description:
 * @param {*}
 * @return {*}
 */
void EthBuffInit(uint8 CtrlIdx);
/**
 * @description:
 * @param {uint8} CtrlIdx
 * @return {*}
 */
void EthBuffDeInit(uint8 CtrlIdx);
/**
 * @description:
 * @param {*}
 * @return {*}
 */
sint32 EthBuffAlloc(uint8 CtrlIdx, uint16 *Len, uint8 **Bufptr, \
                    Eth_BufIdxType *BufIdxptr, boolean rx);
/**
 * @description:
 * @param {uint8} CtrlIdx
 * @param {Eth_BufIdxType} BufIdx
 * @param {boolean} rx
 * @return {*}
 */
void EthBuffFree(uint8 CtrlIdx, Eth_BufIdxType BufIdx, boolean rx);
/**
 * @description:
 * @param {*}
 * @return {*}
 */
uint32 EthBuffAddr(uint8 CtrlIdx, Eth_BufIdxType BufIdx, boolean rx);
/**
 * @description: from buff addr get buf idx
 * @param {uint8} CtrlIdx
 * @param {Eth_DataType *} Bufaddr
 * @param {boolean} rx
 * @return Eth_BufIdxType
 */
Eth_BufIdxType EthBuffIdxFormAddr(uint8 CtrlIdx, const Eth_DataType *Bufaddr, boolean rx);
/**
 * @description:
 * @param {uint8} CtrlIdx
 * @param {boolean} rx
 * @return buf count
 */
uint32 EthGetBufferCount(uint8 CtrlIdx, boolean rx);
/**
 * @description:
 * @param {uint8} CtrlIdx
 * @param {Eth_BufIdxType} BufIdx
 * @param {boolean} rx
 * @return {*}
 */
uint32 EthBuffIsAllocated(uint8 CtrlIdx, Eth_BufIdxType BufIdx, boolean rx);
/**
 * @description:
 * @param {uint8} CtrlIdx
 * @param {Eth_BufIdxType} BufIdx
 * @param {boolean} rx
 * @return {*}
 */
uint32 EthBuffGetSizeByIdx(uint8 CtrlIdx, uint16 BufIndex, boolean rx);
#ifdef __cplusplus
}
#endif

#endif



